package com.application.lucky.fragment.main;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.application.lucky.R;
import com.application.lucky.activity.WebViewActivity;
import com.application.mylibrary.base.BaseFragment;

import com.application.mylibrary.utils.ToastUtils;
import com.application.mylibrary.widget.RefreshView;
import com.qunar.im.ui.view.bigimageview.tool.utility.ui.ToastUtil;
import com.qunar.im.ui.view.recyclerview.BaseQuickAdapter;
import com.qunar.im.ui.view.recyclerview.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

public class FragmentActivity extends BaseFragment {

    //    private com.application.mylibrary.widget.RefreshView rfvView;
    private android.support.v7.widget.RecyclerView rclView;

    @Override
    protected void beforeInit(Bundle arguments) {

    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_activity;
    }

    private Adapter adapter;
    private int page;

    @Override
    public void initView(View view) {

//        rfvView = view.findViewById(R.id.rfv_view);
        rclView = view.findViewById(R.id.rcl_view);
        rclView.setLayoutManager(new LinearLayoutManager(mCOntext));
        adapter = new Adapter(R.layout.item_activity_layout);
        rclView.setAdapter(adapter);
//        rfvView.setRefreshListener(new RefreshView.RefreshListener() {
//            @Override
//            public void onRefresh() {
//                rfvView.setFinish();
//            }
//        });

        initListener();
        loadData();


    }

    private void initListener() {
//        rfvView.setRefreshListener(new RefreshView.RefreshListener() {
//            @Override
//            public void onRefresh() {
//                loadData();
//            }
//        });
        adapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                WebViewActivity.jump(mCOntext, "https://www.baidu.com");
            }
        });

    }

    private void loadData() {

        List<String> strings = new ArrayList<>();
        for (int i = 2; i > 0; i--) {
            strings.add("i");
        }
        adapter.setNewData(strings);

    }

    static class Adapter extends BaseQuickAdapter<String, BaseViewHolder> {
        public Adapter(int layoutResId) {
            super(layoutResId);
        }

        @Override
        protected void convert(BaseViewHolder helper, String item) {

        }
    }
}
